window.shootPeople = window.shootPeople || {};
shootPeople.DevilManager = function () {
    var s = this;
    annie.Sprite.call(s);
    /*_a2x_need_start*//*_a2x_need_end*/
    annie.initRes(s, "shootPeople", "DevilManager");
};
A2xExtend(shootPeople.DevilManager, annie.Sprite);
shootPeople.DevilManager.enemyPool = [];//恶魔池
/*获取恶魔方法*/
shootPeople.DevilManager.getEnemy = function () {
    var s = this,
        enemy;
    if (s.enemyPool.length > 0) {
        enemy = s.enemyPool.shift();
    } else {
        enemy = new shootPeople.Devil();//生成小恶魔
    }
    return enemy;//返回小恶魔类实例
};
/**
 * 恶魔回收
 * @param enemy
 */
shootPeople.DevilManager.recoveryEnemy = function (enemy, type) {
    var s = this;
    if (!enemy) {
        throw new Error('enemy参数不能为空');
    }
    if(type){
        if (!enemy["" + type].hasEventListener(annie.Event.END_FRAME)) {
            enemy["" + type].addEventListener(annie.Event.END_FRAME, function (e) {
                enemy.visible = false;
                enemy.gotoAndStop(1);
                enemy.motion = "";
                s.enemyPool.push(enemy);
            })
        }
    }else{
        enemy.visible = false;
        enemy.gotoAndStop(1);
        enemy.motion = "";
        s.enemyPool.push(enemy);
    }
};
